<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<jsp:include page="../common/common.jsp">
	<jsp:param name="title" value="组群"/>
</jsp:include>

<div class="page-header">
	<h1>
		组群列表
	</h1>
</div>

<div class="row">
	<div class="col-xs-12">
		<div class="row">
			<div class="col-xs-12">
				<div>
					<div class="dataTables_wrapper form-inline no-footer">
						<table id="_table" class="table table-striped table-bordered table-hover dataTable no-footer">
						</table>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>

<!-- page specific plugin scripts -->
<script type="text/javascript">
	$('.page-content-area').ace_ajax('loadScripts', scripts, function() {
		jQuery(function($) {

			// 列表(jquery.table.min.js中定义了table)
    		var $table = $("#_table").table({
    			//请求后台的URL（*）
    			url : "${_path}/admin/group/list",
    			//formId : "_form",
				tools : [
					{text : '新增', clazz : 'btn-info', icon : 'fa fa-plus-circle blue', permission : '/admin/group/edit', handler : function(){
						$.aceRedirect("${_path}/admin/group/edit");
					}},
					{text : '删除', clazz : 'btn-danger', icon : 'fa fa-trash-o red', permission : '/admin/group/delete', handler : function(){						
						$table.ajaxEnable({url : "${_path}/admin/group/delete"}, true);
					}},
					{text : '查看组员', clazz : 'btn-purple', icon : 'fa fa-file-text-o purple', permission : '/admin/group/list/member', handler : function(){
						if($table.validateSelected(true)){
							$.aceRedirect("${_path}/admin/group/list/page?id=" + $table.getSelectedItemKeys("id"));
						}
					}}
				],
				//表格的列
				columns : [
			        {field:'id', hide : true},
			        {field:'isEnable', hide : true},
			        {field:'pid', hide : true},
			        {field:'name', title:'群组名', align:'left'},
			        {field:'description', title:'群组描述', mobileHide : true}
				],
				operate : [
					{text : '修改', clazz : 'blue', icon : 'fa fa-pencil', permission : '/admin/group/edit', handler : function(d, i){
						$.aceRedirect("${_path}/admin/group/edit?id=" + d.id);
					}},
					{text : '查看组员', clazz : 'purple', icon : 'fa fa-file-text-o', permission : '/admin/group/list/member', handler : function(d, i){
						$.aceRedirect("${_path}/admin/group/list/page?id=" + d.id);
					}}
				],
				after : function(){
					// 权限处理
					$.permission();
				}
			});
			
			//搜索
			$(".search-data").keyup(function () { 
				$table.search();
			});
            
			// 取消
			$("#_cancel").click(function(){
				$table.search();
			});
		});
	});
</script>
